package cn.lanqiao.springboot.service;

import cn.lanqiao.springboot.entity.Role;
import cn.lanqiao.springboot.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Autowired
    RedisTemplate<String,Object> redisTemplate;


    public List<Role> selectAllRoles() {
        return roleMapper.selectAllRoles();
    }

    public void updateRole(Role role) {
        roleMapper.updateRole(role);
        redisTemplate.opsForValue().getAndDelete("menuList:" + role.getRoleId());
    }
}
